<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Requests\ClothingSpecRequest;
use App\Http\Controllers\Controller;

use App\Http\Model\ClothingSpec;

class ClothingController extends Controller
{
    public function specList(){
    	$spec = new ClothingSpec;
    	$specInfo = $spec->get();
    	return view("admin.clothing.spec-list", ["specInfo"=>$specInfo]);
    }
    public function specAdd(){
    	return view("admin.clothing.spec-add");
    }
    public function specAddRes(ClothingSpecRequest $request){
    	$spec = new ClothingSpec;
    	$spec->name = $request->input("name");
    	$spec->save();
    	return redirect('admin/spec-list')->with('success','规格新增成功');
    }
    public function specUpdate($id){
    	$spec = new ClothingSpec;
    	$specInfo = $spec->find($id);
    	return view("admin.clothing.spec-update", ["specInfo"=>$specInfo]);
    }
    public function specUpdateRes(ClothingSpecRequest $request){
    	$spec = new ClothingSpec;
    	$specInfo = $spec->find($request->input("id"));
    	$specInfo->name = $request->input("name");
    	$specInfo->save();
    	return redirect('admin/spec-list')->with('success','规格修改成功');
    }
    public function specDelete(Request $request){
    	$spec = new ClothingSpec;
    	$spec->destroy($request->input("id"));
    	echo 1;die;
    }
}
